package com.ojoin.trade.supplyloan_core.web.service.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.web.dao.BaseDao;
import com.ojoin.trade.common.web.service.impl.BaseServiceImpl;
import com.ojoin.trade.common_core.web.service.impl.DataVersionValidationService;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlLoanInfoDao;
import com.ojoin.trade.supplyloan_core.web.domain.SlLoanNotPaybackVo;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlLoanDailyBillVo;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlLoanInfo;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlLoanInfoVo;
import com.ojoin.trade.supplyloan_core.web.service.TbSlLoanInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-27
 * Time: 下午1:20
 * To change this template use File | Settings | File Templates.
 */
@Service
public class TbSlLoanInfoServiceImpl extends BaseServiceImpl<TbSlLoanInfo> implements TbSlLoanInfoService {

    @Autowired
    private TbSlLoanInfoDao dao;

    @Autowired
    private DataVersionValidationService validationService;

    @Override
    protected BaseDao<TbSlLoanInfo> getBaseDao() {
        return dao;  //To change body of implemented methods use File | Settings | File Templates.
    }



    @Override
    public void insertTbSlLoanInfo(TbSlLoanInfo infovo) throws BusinessException {
        ((TbSlLoanInfoDao)this.getBaseDao()).insertSlLoanInfo(infovo);
    }

    @Override
    public int updateTbSlLoanInfo(Map<String, Object> paramsmap) throws BusinessException {
        return ((TbSlLoanInfoDao)this.getBaseDao()).updateSlLoanInfo(paramsmap);
    }


    @Override
    public TbSlLoanInfo queryTbSlLoanInfoByJoinid(int joinid) throws BusinessException {
        return ((TbSlLoanInfoDao)this.getBaseDao()).querySlLoanInfoByJoinid(joinid);
    }

    @Override
    public TbSlLoanInfo queryLoanInfoByJoinid(int joinid) throws BusinessException {
        return  ((TbSlLoanInfoDao)this.getBaseDao()).queryLoanInfoByJoinid(joinid);
    }

    @Override
    public List<TbSlLoanInfoVo> queryAllTbSlLoanInfo() throws BusinessException {
        return ((TbSlLoanInfoDao)this.getBaseDao()).queryAllSlLoanInfoVo();
    }

    @Override
    public void updateCaculateFee() throws BusinessException {
        ((TbSlLoanInfoDao)this.getBaseDao()).caculateFee();
        ((TbSlLoanInfoDao) this.getBaseDao()).caculateTotalRenewedAmount();
    }

    @Override
    public long queryTotalNotPayback(int idOfTbMerchantUser) throws BusinessException {
        return    ((TbSlLoanInfoDao)this.getBaseDao()). queryTotalNotPayback(idOfTbMerchantUser);
    }

    @Override
    public List<SlLoanNotPaybackVo> queryPlatformLoanInfoByJoinid(int idOfTbMerchantUser) throws BusinessException {
        return   ((TbSlLoanInfoDao)this.getBaseDao()).queryPlatformLoanInfoByJoinid(idOfTbMerchantUser);
    }

    @Override
    public void lockId(int id) throws BusinessException {
        ((TbSlLoanInfoDao)this.getBaseDao()).lockid(id);

    }

    @Override
    public void lockTable() throws BusinessException {
        ((TbSlLoanInfoDao)this.getBaseDao()).lockTable();
    }

    @Override
    public void updateForCopyLoanInfo() throws BusinessException {
        ((TbSlLoanInfoDao)this.getBaseDao()).updateForCopySlloanInfo();
    }

    @Override
    public List<TbSlLoanDailyBillVo> queryDailyBill(String curdate,Integer idOfTbMerchantUser,Integer idOfTbMerchantUserOfCreditor,Pageable pageable) throws BusinessException {
        return  ((TbSlLoanInfoDao)this.getBaseDao()).queryDailyBill(curdate,idOfTbMerchantUser,idOfTbMerchantUserOfCreditor,pageable);
    }

    @Override
    public String queryDailySum(String curdate, Integer idOfTbMerchantUser,Integer idOfTbMerchantUserOfCreditor) throws BusinessException {
        return ((TbSlLoanInfoDao)this.getBaseDao()).queryDailySum(curdate,idOfTbMerchantUser,idOfTbMerchantUserOfCreditor);
    }

}
